package backend.ro.msg.gillardon.timer;

import java.io.Serializable;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.ejb.ScheduleExpression;
import javax.ejb.Singleton;
import javax.ejb.Startup;
import javax.ejb.Timeout;
import javax.ejb.TimerService;

import org.apache.log4j.Logger;

@Singleton
@Startup
public class Timer2 implements Serializable {

  private final static Logger LOG = Logger.getLogger(Timer2.class);
  private static final long serialVersionUID = 1L;
  @Resource
  private TimerService timerService;

  public Timer2() {
    super();
  }

  @PostConstruct
  public void aftrConstructor() {
    ScheduleExpression expr = new ScheduleExpression();
    expr.second("4,56").minute("15").hour("14");
    this.timerService.createCalendarTimer(expr);

  }

  @Timeout
  public void timeoutMethod() {
    LOG.debug("Timer2: " + System.currentTimeMillis());
  }
}
